package com.ego.controller;

import com.ego.commons.pojo.EasyUITree;
import com.ego.commons.pojo.EgoResult;
import com.ego.pojo.TbContentCategory;
import com.ego.service.TbContentCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class TbContentCategoryController {

        @Autowired
        private TbContentCategoryService tbContentCategoryService ;
    /**
     * 显示内容分类树状菜单
     * @param id 父id    第一次不传数据  所以设定默认值为0
     * @return easyui tree要的数据
     */
        @RequestMapping("/content/category/list")
        public List<EasyUITree> showContentCategory(@RequestParam(defaultValue = "0") long id){
            return tbContentCategoryService.showContentCategory(id);
        }

    /**
     * 新增节点
     * @param category
     * @return
     */
    @RequestMapping("/content/category/create")
        public EgoResult insert(TbContentCategory category){
            return tbContentCategoryService.insert(category);
        }

    /**
     * 修改  重命名
     * @param tbContentCategory
     * @return
     */
    @RequestMapping("/content/category/update")
    public EgoResult update(TbContentCategory tbContentCategory){
        return tbContentCategoryService.update(tbContentCategory);
    }

    /**
     * 删除(修改状态)
     * @param id
     * @return
     */
    @RequestMapping("/content/category/delete")
    public EgoResult delete(Long id) {
        return tbContentCategoryService.delete(id);
    }
}
